package com.dragon.mmochat.model;

import com.dragon.mmochat.MmochatConstant;
import com.dragon.mmochat.model.enumType.MmochatDelayPayState;
import com.dragon.mmochat.model.enumType.MmochatPhoneCardType;

public class MmochatDelayPay implements Comparable<MmochatDelayPay> {
	private static MmochatSerial serial = new MmochatSerial();
	private int id;// 订单号
	private int roleId;// 用户ID
	private MmochatPhoneCardType type;// 充值卡类型
	private int money = 0;// 金额
	private int trueMoney = 0;// 实际金额
	private int bigMoney = 0;// 实发元宝
	private String account = null;// 卡号
	private String password = null;// 密码
	private long createTime = System.currentTimeMillis();// 创建时间
	private MmochatDelayPayState state = MmochatDelayPayState.创建中;
	private String hint = "等待受理";
	private Integer dealGmId = null;// 受理的GM

	public MmochatDelayPay() {
		id = serial.addAndGetSerialId();
	}

	public void resetId() {
		id = serial.addAndGetSerialId();
	}

	public boolean isAccountOk() {
		if (account == null || account.length() != type.getAccountLength()) {
			return false;
		}
		return true;
	}

	public boolean isPasswordOk() {
		if (password == null || password.length() != type.getPasswordLength()) {
			return false;
		}
		return true;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public int getRoleId() {
		return roleId;
	}

	public void setRoleId(int roleId) {
		this.roleId = roleId;
	}

	public MmochatPhoneCardType getType() {
		return type;
	}

	public void setType(MmochatPhoneCardType type) {
		this.type = type;
	}

	public int getMoney() {
		return money;
	}

	public void setMoney(int money) {
		this.money = money;
	}

	public String getAccount() {
		return account;
	}

	public void setAccount(String account) {
		this.account = account;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public long getCreateTime() {
		return createTime;
	}

	public void setCreateTime(long createTime) {
		this.createTime = createTime;
	}

	public MmochatDelayPayState getState() {
		return state;
	}

	public void setState(MmochatDelayPayState state) {
		this.state = state;
	}

	public String getHint() {
		return hint;
	}

	public void setHint(String hint) {
		this.hint = hint;
	}

	public boolean isTimeOut() {
		if (state == MmochatDelayPayState.创建中) {
			if (System.currentTimeMillis() - createTime > 3 * MmochatConstant.MS_PER_HOUR) {
				return true;
			}
		}
		return false;
	}

	public Integer getDealGmId() {
		return dealGmId;
	}

	public void setDealGmId(Integer dealGmId) {
		this.dealGmId = dealGmId;
	}

	public int getBigMoney() {
		return bigMoney;
	}

	public void setBigMoney(int bigMoney) {
		this.bigMoney = bigMoney;
	}

	public int getTrueMoney() {
		return trueMoney;
	}

	public void setTrueMoney(int trueMoney) {
		this.trueMoney = trueMoney;
	}

	@Override
	public int compareTo(MmochatDelayPay o) {
		return (int) ((o.getCreateTime() - createTime) / MmochatConstant.MS_PER_MINUTE);
	}

}
